<?php

namespace Application\Model;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

class Inscription {
	
	private $nom;
	private $prenom;
	private $fonction;
	private $entreprise;
	private $adresse;
	private $email;
	private $telephone;
	private $login;
	private $password;
	private $motif;
	protected $inputFilter;
	
	public function exchangeArray($data){
		$this->nom        = (isset($data['nom'])) ? $data['nom'] : null;
		$this->prenom        = (isset($data['prenom'])) ? $data['prenom'] : null;
		$this->fonction        = (isset($data['fonction'])) ? $data['fonction'] : null;
		$this->adresse        = (isset($data['adresse'])) ? $data['adresse'] : null;
		$this->entreprise        = (isset($data['entreprise'])) ? $data['entreprise'] : null;
		$this->email        = (isset($data['email'])) ? $data['email'] : null;
		$this->login        = (isset($data['login'])) ? $data['login'] : null;
		$this->password     = (isset($data['password'])) ? $data['password'] : null;
		$this->password2     = (isset($data['password2'])) ? $data['password2'] : null;
		$this->motif        = (isset($data['motif'])) ? $data['motif'] : null;
		$this->date_inscrip        = (isset($data['date_inscrip'])) ? $data['date_inscrip'] : null;
	}
	
	
	public function getArrayCopy()
	{
		return get_object_vars($this);
	}
	
	public function setInputFilter(InputFilterInterface $inputFilter)
	{
		throw new \Exception("Not used");
	}
	
	public function getInputFilter(){
		if(!$this->inputFilter){
				
			$inputFilter = new InputFilter();
			$factory     = new InputFactory();

			$inputFilter->add($factory->createInput(array(
					'name'     => 'nom',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 2,
											'max'      => 20,
									),
							),
					),
			)));
				
			$inputFilter->add($factory->createInput(array(
					'name'     => 'prenom',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 2,
											'max'      => 25,
									),
							),
					),
			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'email',
					'required' => true,
					'validators' => array(
							array(
									'name'    => 'EmailAddress'
							),
					),
			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'adresse',
					'required' => true,

			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'telephone',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 6,
											'max'      => 25,
									),
							),
					),
			)));
			
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'login',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 5,
											'max'      => 20,
									),
							),
					),
			)));
	
			$inputFilter->add($factory->createInput(array(
					'name'     => 'password',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 5,
											'max'      => 20,
									),
							),
					),
			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'motif',
					'validators' => array(
							array(
									'name'    => 'InArray',
									'options' => array(
											'haystack' => array('Forum','Client'),
											'messages' => array(
													'notInArray' => 'Selectionnez l\'objet de votre inscription !'
											),
									),
							),
					),
			)));
	
			$this->inputFilter = $inputFilter;
		}
	
		return $this->inputFilter;
	}
}

?>